home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / examples / sfft < prev    next >
Text File  |  1994-09-20  |  355b  |  26 lines

  1. //
  2. // Calculate Fourier transform of a finite signal (SLOWLY)
  3. //
  4.  
  5. sfft = function ( x )
  6. {
  7.   global (pi)
  8.  
  9.   if(class (x) != "num") 
  10.   {
  11.     error ("input to sfft must be a matrix");
  12.   }
  13.  
  14.   X = zeros ( size (x) );
  15.   
  16.   for( k in 1:x.n )
  17.   {
  18.     for( n in 1:x.n )
  19.     {
  20.       X[k] = X[k] + x[n]*exp( (-1i*2*pi*(k-1)*(n-1))/x.n );
  21.     }
  22.   }
  23.   
  24.   return X;
  25. };
  26.